package com.zgis.module.data.control;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.zgis.module.data.service.SvrDataServiceImpl;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 修改记录:
 * 24-09-29     zhengchaojun             首次创建
 */

/**
 * 类描述：通用服务(增，删，改，查)
 */
@Tag(name = "管理后台 - data模块")
@Validated
@Slf4j
@RestController
@RequestMapping("zgis/DataSvr")
public class DataSvrControl
{
    @Resource(name = "svrDataServiceImpl")
    private SvrDataServiceImpl svrDataService;

    @PostMapping({"/queryId"})
    public ObjectNode queryId(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.queryId(params);
    }

    @PostMapping({"/queryId0"})
    public ObjectNode queryId0(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.queryId0(params);
    }

    @PostMapping({"/queryAll"})
    public ObjectNode queryAll(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.queryAll(params);
    }

    @PostMapping({"/query"})
    public ObjectNode query(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.query(params, '1');
    }

    @PostMapping({"/querySql"})
    public ObjectNode querySql(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return (ObjectNode) svrDataService.querySql(params, '1');
    }

    @PostMapping({"/querySeq"})
    public ObjectNode querySeq(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.querySeq(params);
    }

    @PostMapping({"/stat"})
    public ObjectNode stat(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.stat(params);
    }

    @PostMapping({"/insertNoId"})
    public ObjectNode insertNoId(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.insertNoId(params);
    }

    @PostMapping({"/insertWithId"})
    public ObjectNode insertWithId(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.insertWithId(params);
    }

    @PostMapping({"/insertsNoId"})
    public ObjectNode insertsNoId(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.insertsNoId(params);
    }

    @PostMapping({"/del"})
    public ObjectNode del(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.del(params);
    }

    @PostMapping({"/dels"})
    public ObjectNode dels(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.dels(params);
    }

    @PostMapping({"/update"})
    public ObjectNode update(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.update(params);
    }

    @PostMapping({"/updates"})
    public ObjectNode updates(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.updates(params);
    }

    @PostMapping({"/callProc"})
    public ObjectNode callProc(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.callProc(params);
    }

    @PostMapping({"/batch"})
    public ObjectNode batch(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.batch(params);
    }

    @RequestMapping(value = {"/init"}, method = {RequestMethod.GET, RequestMethod.POST})
    public ObjectNode init(@RequestParam("_auth") String token, @RequestBody JsonNode params) throws Exception
    {
        return svrDataService.init(params);
    }
}
